<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <title>医生工作站登录</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="/static/script/jquery-1.11.1-min.js"></script>

  <style>
    body {
      background-color: #5b84cd;
      font-family: Arial, sans-serif;
      margin: 0;
      padding: 0;
    }
    h1 {
      color: #0066cc;
      text-align: center;
      width: 900px;
      font-size: 60px;
      position: absolute;
      margin-top: 450px;
    }

    #text {
      background-color: #ffffff;
      border-radius: 10px;
      box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
      padding: 20px;
      max-width: 500px;
      width: 350px;
      height: 200px;
      margin-left: 1000px;
      margin-top: 200px;
      position: absolute;
    }
    input[type="text"], input[type="password"] {
      border: 1px solid #ccc;
      border-radius: 5px;
      display: block;
      font-size: 16px;
      margin-bottom: 20px;
      padding: 8px;
      width: 96%;
    }

    input[type="submit"] {
      background-color: #0066cc;
      border: none;
      border-radius: 5px;
      color: #ffffff;
      cursor: pointer;
      font-size: 16px;
      padding: 10px;
      width: 100%;
    }

    input[type="submit"]:hover {
      background-color: #0f5fb6;
    }
    span{
      color: #EE0A4EFF;
      font-size: 15px;

    }
    #img{
      position: absolute;
      width: 400px;
      height: 350px;
      margin-left: 250px;
      margin-top: 100px;

    }
    #total{
      background-color: #ffffff;
      border-radius: 10px;
      box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
      position: absolute;
      height: 700px;
      width: 1500px;
      margin-top: 20px;
      margin-left: 20px;
    }
  </style>

</head>
<body>
  <div id="total">
    <div id="img" >
        <img src="http://localhost:8080/static/img/图标.png" style="width: 400px;height: 350px">
    </div>
    <div id="text">
      <label for="username">用户名：</label>
      <input type="text" id="username" name="username" value="" required>
      <label for="password">密码：</label>
      <input type="password" id="password" name="password" value="" required>
      <input type="submit" value="登录" id="submit">
      <span id="msg"></span>
    </div>
    <h1>医生工作站登录</h1>
  </div>
</body>
<script type="text/javascript">
  //登录按钮单击事件
  $("#submit").click(function (){
    var username=$("#username").val();
    var password=$("#password").val();
    if(username==""){
      alert("用户名不能为空");
    }else if(password==""){
      alert("密码不能为空");
    }else{
      $.ajax({
        url:'/login',
        data:{
          username:username,
          password:password
        },
        type:'post',
        dataType:'json',
        success:function (data){
          if (data.code=='1'){
            window.location.href="main/index";
          }else{
            $("#msg").text(data.message);
          }
        }
      })
    }
  });
  //输入框enter事件
  $("#username").keyup(function (event){
      if(event.keyCode===13){
        $("#submit").trigger("click")
      }
  })
  $("#password").keyup(function (event){
    if(event.keyCode===13){
      $("#submit").trigger("click")
    }
  })
</script>
</html>
